package cloud.demarcia.rabbitregister.constant;

import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;

/**
 * @author Bojun Wen, wen_bj@outlook.com
 * @date 2022.02.19
 */

public class RsaKey {
    private static final byte[] privateKey;
    private static final byte[] publicKey;

    static {
        ClassPathResource resource1 = new ClassPathResource("priv.key");
        privateKey = resource1.readBytes();
        ClassPathResource resource2 = new ClassPathResource("pub.key");
        publicKey = resource2.readBytes();
    }
    private RsaKey(){}

    public static String getPublicKeyStr() {
        return StrUtil.str(publicKey, CharsetUtil.defaultCharset());
    }

    public static String getPrivateKeyStr() {
        return StrUtil.str(privateKey, CharsetUtil.defaultCharset());
    }
}
